package main

import (
	"rate/common/filter"
	_ "rate/routers"

	"github.com/beego/beego/v2/core/logs"
	beego "github.com/beego/beego/v2/server/web"
)

func main() {
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
		// 日志
		beego.BConfig.Log.AccessLogs = true
		logs.Async()
		_ = logs.SetLogger(logs.AdapterConsole)
	}
	// 错误处理controller
	//beego.ErrorController(&controllers.ErrorController{})
	_ = logs.SetLogger(logs.AdapterFile, `{"filename":"logs/log.log","level":1,"maxlines":10240,"maxsize":10240,"daily":true,"maxdays":10,"color":true}`)
	// 过滤器
	beego.InsertFilter("/v1/tunnel/*", beego.BeforeRouter, filter.LoginFilter)
	beego.Run()
}
